#pragma once

#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

using namespace std;

class FrameBufferObject
{
	public:
		FrameBufferObject();

		void Bind(int color_buffer_index = 0);
		void Unbind();
		bool Initialize(glm::ivec2 size, int number_of_color_attachments = 1, bool allocate_depth_buffer = true);
		void TakeDown();

		GLuint GetFrameBufferHandle();
		GLuint GetDepthBufferHandle();
		GLuint * GetTextureHandles();

		glm::ivec2 GetSize();
		int GetNumColorAttachments();

	private:
		GLuint frame_buffer_handle;
		GLuint depth_buffer_handle;
		GLuint * texture_handles;

		glm::ivec2 size;
		int num_color_attachments;

		bool CheckGLErrors();
};
